# class Fib():  #
#     def __init__(self):
#         self.pre = 0
#         self.cur = 1
#
#     def __iter__(self):  #返回自身
#         return self
#
#     def __next__(self):  #返回下一个值
#         result = self.cur
#         self.pre, self.cur = self.cur, self.cur+self.pre
#         return result
# f = Fib()
# print([next(f) for i in range(20)])

#################
#################
#################

#自定义异常类  -- 继承exception
class ListError(Exception):
    def __init__(self):
        pass
    def __str__(self):
        return "ListError：list内元素长度超过10"

def lst_length(lst1):
    if len(lst1) > 10:
        raise ListError
    else:
        print(len(lst1))

lst = [1,2,3,4,5,6,7,8,9,10,11]
try:
    lst_length(lst)
except ListError:
    print(ListError())



